//
// Created by fanghr on 17-12-30.
//

#ifndef PROJECT_RAW_DATA_H
#define PROJECT_RAW_DATA_H
#include "../../include.h"
#include "global_var.h"
#include "rw_lock.h"

#define DEBUG
int get_raw(int device, cam_global::mat_pack_t &mat_pack) {
    cv::VideoCapture cap(device);
    if (!cap.isOpened())return -1;
    cap.set(CV_CAP_PROP_FRAME_HEIGHT, 200);
    cap.set(CV_CAP_PROP_FRAME_WIDTH, 200);
#ifdef DEBUG
    cv::namedWindow("DEBUG",cv::WINDOW_NORMAL);
#endif
    cv::Mat frame;
    while (1) {
        mat_pack.lock.lock();
        cap >> frame;
        mat_pack.mat = frame;
#ifdef DEBUG
        cv::imshow("DEBUG",mat_pack.mat);
        cv::waitKey(10);
#endif
        mat_pack.lock.unlock();
    }
}
#endif //PROJECT_RAW_DATA_H
